<form action="" method="post">
    <input type="text" name="keyword">
    <input type="submit" name="sub" value="搜索">
</form>
<?php
/**
 * User: lie
 * Date: 2020/12/8 8:25
 * Title:  查询关键字描红
 * Description:
 * Error:
 */
if ($_POST['sub']) {
    $keyword = $_POST['keyword'];
    if (!empty($keyword)) {
        require("conn.php");
            echo "<table border='1' cellpadding='0' cellspacing='.'>";
            $sql = "SELECT * FROM customer WHERE cCName like '%".$keyword."%'";
            $redfont = "<b style='color: red'>$keyword</b>";
            $result = $mysqli->query($sql);
            if ($result!= false) {
                echo "<table border='1' cellspacing='0' cellpadding='0'>";
                echo "<td>客户编码</td>";
                echo "<td>客户名称</td>";
                echo "<td>客户简称</td>";

                while ($resarr = $result->fetch_array()) {
                    $res = str_replace($keyword, $redfont, $resarr);
                    echo "<tr>";
                    echo "<td>".$res['cCuscode']."</td>";
                    echo "<td>".$res['cCName']."</td>";
                    echo "<td>".$res['cCusAbbName']."</td>";
                    echo "</tr>";
                }
                echo "</table>";
            }
            echo "</table>";
    } else {
        return false;
    }
}